<?php
//So linh vuc hien thi tren mot trang
$v_limit = CONST_LIMIT_AGENCY_PER_PAGE ;
if(isset($_REQUEST['page'])){
	$page=$_REQUEST['page'];
}
else
	$page=1;
if(_is_sqlserver()){
	// Lay so luong linh vuc
	$cmd = @mssql_init("ONEGATE_AFCateCountAll", $conn);
	$result_count_cate = @mssql_execute($cmd);
	$arr_count_cate = _get_row_to_array($result_count_cate);
	@mssql_free_result($result_count_cate);

	$v_total_cate_count =$arr_count_cate['0']['0'];
	$pager  = Pager::getPagerData($v_total_cate_count, $v_limit, $page);
	$page   = $pager->page;
  	$offset = $pager->offset +1; 
  	$limit = $pager->limit;

	//Lay danh sach linh vuc
	$cmd = @mssql_init("ONEGATE_AFCateGetAll",$conn);//Phai viet lai
	@mssql_bind($cmd,"@offset", $offset,SQLINT4);	
	@mssql_bind($cmd,"@limit",$limit,SQLINT4);		
	$rs_all_cate = @mssql_execute($cmd);
	$arr_all_cate = _get_row_to_array($rs_all_cate); 
	@mssql_free_result($rs_all_cate);

	//Lay danh sach CQHC 
	$v_agency = CONST_LIMIT_CATE_PER_AGENCY;
	$cmd = @mssql_init("ONEGATE_AFAgencyGetByAllCate",$conn);//Phai viet lai
	@mssql_bind($cmd,"@offset", $offset,SQLINT4);	
	@mssql_bind($cmd,"@limit",$limit,SQLINT4);	
	@mssql_bind($cmd,"@p_number", $v_agency,SQLINT4);		
	$result = @mssql_execute($cmd);
	$arr_all_agency = _get_row_to_array($result); 
	@mssql_free_result($result);
}?>